import re

html = '''
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document
    </title>
</head>
<body>
    <ul>
        <li><a href="www.baidu1.com">链接1</a></li>
        <li><a href="www.baidu2.com">链接2</a></li>
        <li><a href="www.baidu3.com">链接3</a></li>
        <li><a href="www.baidu4.com">链接4</a></li>
        <li><a href="www.baidu5.com">链接5</a></li>
    </ul>
</body>
</html>
'''



# result = re.search(r'<title>Document1</title>',html)
# print(result)

result = re.search(r'<title>(.*?)</title>',html,re.S).group(1)
if result:
    print(result.strip())
else:
    print("匹配失败")


# result = re.findall(r'<title>(.*?)</title>',html,re.S)
# for item in result:
#     print(item.strip())


# result = re.findall(r' <li><a href="(.*?)">(.*?)</a></li>',html)
# for r in result:
#     print(r)









